Ignore only root target directory
authorAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 25 May 2017 16:47:15 +0000 (19:47 +0300)
committerAleksey Kladov <aleksey.kladov@gmail.com>
Thu, 25 May 2017 16:47:15 +0000 (19:47 +0300)
We used to ignore all target directories, because it was common to
have multiple packages with different target directories in a single
repository. Now, when workspaces are here, such setups usually have a
single target, and we can .gitignore only it. It's useful because
sometimes you want to have a module named `target` in Rust.

If you use non-workspaced multi-package setup, you can create a
.gitignore with `/target/` for each package.

src/cargo/ops/cargo_new.rs

index 5b4f4faaede9b779adbb072081cbbb5f4189c1e8..9e08eee13c79d052654cba221e66b8c9e41cd32e 100644 (file)
@@ -384,7 +384,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
     let path = opts.path;
     let name = opts.name;
     let cfg = global_config(config)?;
-    let ignore = ["target/\n", "**/*.rs.bk\n",
+    let ignore = ["/target/\n", "**/*.rs.bk\n",
         if !opts.bin { "Cargo.lock\n" } else { "" }]
         .concat();